package com.colorlight.cloud.complete.entity.enumerate;

import com.colorlight.cloud.common.exception.BaseException;
import com.colorlight.cloud.gateway.api.message.constraint.basics.ienum.EnumTrans;
import lombok.Getter;

import java.util.Objects;

/**
 * @author Demon
 * @description TODO
 * @date 25/3/2024  下午5:10
 */
@Getter
public enum NetworkChannel implements EnumTrans<Integer, NetworkChannel> {
	/**
	 * 默认结果
	 * 成功上传
	 * 上传失败-访问URL失败
	 * 失败上传 未知异常
	 */
	
	HZ5G,
	HZ2_4G;
	
	
	private static final long serialVersionUID = 741963852741963852L;
	/**
	 * 频道分界值
	 */
	private final static Integer CRITICAL_VALUE = 25;
	
	
	@Override
	public Integer toProto() {
		throw new BaseException("无效设置属性");
	}
	
	@Override
	public NetworkChannel formProto(Integer integer) {
		if (Objects.isNull(integer)) {
			throw new NullPointerException("空指针异常");
		}
		
		return integer < CRITICAL_VALUE? HZ2_4G:HZ5G;
	}
}

